package com.letian.web.controller.info;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.letian.common.annotation.Log;
import com.letian.common.core.controller.BaseController;
import com.letian.common.core.domain.AjaxResult;
import com.letian.common.enums.BusinessType;
import com.letian.info.domain.InfoFeedback;
import com.letian.info.service.IInfoFeedbackService;
import com.letian.common.utils.poi.ExcelUtil;
import com.letian.common.core.page.TableDataInfo;

/**
 * 反馈信息Controller
 * 
 * @author bmz
 * @date 2023-04-09
 */
@RestController
@RequestMapping("/info/feedback")
public class InfoFeedbackController extends BaseController
{
    @Autowired
    private IInfoFeedbackService infoFeedbackService;

    /**
     * 查询反馈信息列表
     */
    @PreAuthorize("@ss.hasPermi('info:feedback:list')")
    @GetMapping("/list")
    public TableDataInfo list(InfoFeedback infoFeedback)
    {
        startPage();
        List<InfoFeedback> list = infoFeedbackService.selectInfoFeedbackList(infoFeedback);
        return getDataTable(list);
    }

    /**
     * 导出反馈信息列表
     */
    @PreAuthorize("@ss.hasPermi('info:feedback:export')")
    @Log(title = "反馈信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InfoFeedback infoFeedback)
    {
        List<InfoFeedback> list = infoFeedbackService.selectInfoFeedbackList(infoFeedback);
        ExcelUtil<InfoFeedback> util = new ExcelUtil<InfoFeedback>(InfoFeedback.class);
        util.exportExcel(response, list, "反馈信息数据");
    }

    /**
     * 获取反馈信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('info:feedback:query')")
    @GetMapping(value = "/{feedbackId}")
    public AjaxResult getInfo(@PathVariable("feedbackId") Long feedbackId)
    {
        return success(infoFeedbackService.selectInfoFeedbackByFeedbackId(feedbackId));
    }

    /**
     * 新增反馈信息
     */
    @PreAuthorize("@ss.hasPermi('info:feedback:add')")
    @Log(title = "反馈信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InfoFeedback infoFeedback)
    {
        infoFeedback.setUserId(getUserId());
        infoFeedback.setCreateBy(getUsername());
        return toAjax(infoFeedbackService.insertInfoFeedback(infoFeedback));
    }

    /**
     * 修改反馈信息
     */
    @PreAuthorize("@ss.hasPermi('info:feedback:edit')")
    @Log(title = "反馈信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InfoFeedback infoFeedback)
    {
        return toAjax(infoFeedbackService.updateInfoFeedback(infoFeedback));
    }

    /**
     * 删除反馈信息
     */
    @PreAuthorize("@ss.hasPermi('info:feedback:remove')")
    @Log(title = "反馈信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{feedbackIds}")
    public AjaxResult remove(@PathVariable Long[] feedbackIds)
    {
        return toAjax(infoFeedbackService.deleteInfoFeedbackByFeedbackIds(feedbackIds));
    }
}
